package com.greenleaf.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.greenleaf.entity.Comment;
import com.greenleaf.entity.SearchCon;
import com.greenleaf.service.CommentService;
@Controller
@RequestMapping("/comment")
public class CommentController {
	
		@Resource
		private CommentService commentService;
		
		@RequestMapping("/getAll")
		@ResponseBody
		//http://localhost:8080/Greenleaf/comment/getAll
		public Object getAllComment(SearchCon searchCon) {
			List<Comment> user = commentService.getAllComment(searchCon);
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("code", "0");
			map.put("msg", "0");
			map.put("count",commentService.getTotalComment(searchCon));
			map.put("data", user);
			return map;
		}
		@RequestMapping("/update")
		@ResponseBody
		//http://localhost:8080/Greenleaf/comment/update
		public Object updateComment(Comment comment) {
			//System.out.println(pdtClass);
			int r = commentService.updateComment(comment);
			return r==1?true:false;
		}
	}

